package com.BaiBai.advice;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(1)//值越小，优先级越高，前置先执行，后置后执行
public class LogAdvice {
    @Before("com.BaiBai.pointcut.MyPointcut.pc()")
    public void start() {
        System.out.println("方法开始了！");
    }
    @After("com.BaiBai.pointcut.MyPointcut.pc()")
    public void end() {
        System.out.println("方法结束了！");
    }
    @AfterThrowing("com.BaiBai.pointcut.MyPointcut.pc()")
    public void exception() {
        System.out.println("方法出现异常了！");
    }
}
